From f1f7b06ee976bb4c141157b66cdf162ff18d0672 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tobias=20Nie=C3=9Fen?= Date: Mon, 18 Aug 2025 14:17:47 +0200 Subject: [PATCH] [PATCH] src: fix order of CHECK_NOT_NULL/dereference MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit `ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS` may dereference `req_wrap_async`, so `CHECK_NOT_NULL(req_wrap_async)` should be used before and not after. PR-URL: https://github.com/nodejs/node/pull/59487 Reviewed-By: Luigi Pinca Reviewed-By: Richard Lau Reviewed-By: Anna Henningsen Reviewed-By: Ulises Gascón Gbp-Pq: Topic sec Gbp-Pq: Name 29-fix-order-of-check-not-null.patch --- src/node_file.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_file.cc b/src/node_file.cc index bba27a4a9..03c3b20b5 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1635,12 +1635,12 @@ static void Unlink(const FunctionCallbackInfo& args) { if (argc > 1) { // unlink(path, req) FSReqBase* req_wrap_async = GetReqWrap(args, 1); + CHECK_NOT_NULL(req_wrap_async); ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS( env, req_wrap_async, permission::PermissionScope::kFileSystemWrite, path.ToStringView()); - CHECK_NOT_NULL(req_wrap_async); FS_ASYNC_TRACE_BEGIN1( UV_FS_UNLINK, req_wrap_async, "path", TRACE_STR_COPY(*path)) AsyncCall(env, req_wrap_async, args, "unlink", UTF8, AfterNoArgs, -- 2.30.2